#ifndef _IO_TOOLS_H_
#define _IO_TOOLS_H_

#include "def.h"
#include <sys/uio.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/un.h>
#include <netinet/in.h>
#include <arpa/inet.h>

#ifdef __cplusplus
extern "C"{
#endif


int fd_read(int fd, void *data, size_t size);
int fd_write(int fd, void *data, size_t len);
int fd_readv(int fd, struct iovec *iov, size_t count);
int fd_writev(int fd, struct iovec *iov, size_t count);

int tcp_server_create(const char *ip_str, uint16_t port, int backlog);
int tcp_server_accept(int sock, struct sockaddr_in *cli_addr);
int tcp_client_create(const char *ip_str, uint16_t port);
int connect_timeout(const char *ip, uint16_t port, int tm);

int udp_server_create(const char *ip_str, uint16_t port);
int udp_client_create(const char *ip_str, uint16_t port);

int unix_tcp_server_create(const char *path, int backlog);
int unix_tcp_client_create(const char *path);

int unix_udp_server_create(const char *path);
int unix_udp_client_create(const char *path);

int fd_set_nonblock(int fd);
int fd_set_block(int fd);

int get_file_size(const char *file_name, off_t *file_size);

#ifdef __cplusplus
}
#endif // end __cplusplus


#endif
